package org.compression.services.imp;

import org.compression.mapper.AudioMapper;
import org.compression.mapper.BaseMapper;
import org.compression.mapper.UserManagmentMapper;
import org.compression.services.BaseService;
import org.compression.util.RedisUtil;
import org.model.auth.PageUser;
import org.model.business.AduioAttr;
import org.model.comm.Page;
import org.model.comm.UpdateModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

public abstract class BaseServiceImp<T extends BaseMapper, M> implements BaseService<M>{

	
	@Autowired
	T mBookMagamentMapper;
//	UserManagmentMapper mBookMagamentMapper;
	@Autowired
	RedisUtil	mRedisUtil;
	
	
	@Override
	public Object getMember(Page mPage) {
		
		
		PageUser m=new PageUser();
	//	Object date=(Object) mRedisUtil.get(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
	//	System.out.println(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
		/*if(date!=null) {
			return date;
		}else {*/
			m.setMember(mBookMagamentMapper.getPageBookMagament(mPage));
			m.setTotal(mBookMagamentMapper.getTotal());
	//		mRedisUtil.set(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize(), m);
		/*}*/
		return m;
	}

	@Override
	public Object selectName(M mBookMagaments) {
		return mBookMagamentMapper.selectName(mBookMagaments);
	}

	@Override
	public Object add(UpdateModel<M> Model) {
		Page mPage =Model.getmPage();
	//	mRedisUtil.del(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
		/*String uuid=UUID.randomUUID().toString();
		if(mBookMagamentMapper.selectUUID(uuid).size()<=0) {
		}else {
			 uuid=UUID.randomUUID().toString();
		}
		((AduioAttr) mBookMagament.getmBookMagament()).setUuid(uuid);*/
		return mBookMagamentMapper.insertSelective(Model.getmBookMagament());
	}

	@Override
	public void deleteByPrimaryKey(UpdateModel<M> mAddModel) {
		Page mPage =mAddModel.getmPage();
		//mRedisUtil.del(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
		mBookMagamentMapper.deleteByPrimaryKey((mAddModel.getmBookMagament()));
	}

	@Override
	public void updateByPrimaryKeySelective(UpdateModel<M> mAddModel) {
		Page mPage =mAddModel.getmPage();
		//mRedisUtil.del(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
		mBookMagamentMapper.updateByPrimaryKeySelective(mAddModel.getmBookMagament());
	}

	
	
	
	
	
}
